#include <stdio.h>
#include <fcntl.h>
#include <sys/select.h>

void main()
{
  char b[1];
  int n;
  //FILE *f;
  int f, rv; 
  fd_set set;
  struct timeval timeout;

  f = open("/dev/musb2lpt", O_RDWR);
  if (f == -1) {
  	printf("Could not open file\n");
  	return;
  }
  FD_ZERO(&set);
  FD_SET(f,&set);

  timeout.tv_sec = 0;
  timeout.tv_usec = 10000;

  n = write(f,"\x00\x01",2);
  printf("Wrote = %d\n", n);
  n = write(f,"\x10",1);
  printf("Wrote = %d\n", n);
//  sleep(1);
/*  rv = select(f+1,&set,NULL,NULL, &timeout);
  if (rv == -1)
    perror("select");
  else if (rv == 0)
    perror("timeout");
  else*/
  n = read(f,b,1);
  printf("Read = %d, v = %X\n", n, b[0]);
  close(f);
}
